package main

import (
	"fmt"
	"runtime"

	"github.com/nats-io/nats.go"
)

func main() {
	// Connect to a server
	nc, _ := nats.Connect(nats.DefaultURL)

	// Simple Publisher
	// nc.Publish("hello", []byte("form go sdk"))

	// Simple Async Subscriber
	nc.Subscribe("hello", func(Msg *nats.Msg) {
		fmt.Printf("收到的消息是: %s\n", string(Msg.Data))
	})
	runtime.Goexit()
}
